<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>注册</title>
		<link rel="stylesheet" type="text/css" href="css/public.css"/>
		<link rel="stylesheet" type="text/css" href="css/login.css"/>
		<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
		<script src="js/public.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="js/axios.min.js"></script>
		<script type="text/javascript">
			function reg(){
				var utele= document.getElementById("utele").value;
				var uname= document.getElementById("uname").value;
				var upwd= document.getElementById("upwd").value;
				var upass= document.getElementById("upass").value;
				if(utele===""){
					console.log("电话不能为空");
				}else if(uname===""){
					console.log("用户名不能为空");
				}else if(upwd===""){
					console.log("密码不能为空");
				}else if(upass===""){
					console.log("确认密码不能为空");
				}else if(upwd!==upass){
					alert("两次密码不一致");
				}
				else{
					axios.get("http://localhost:8088/users/register",{
						params:{
							'uname': uname,
							'utele': utele,
							'upwd': upwd
						}
					})
					.then(res => {
						console.log(res.data);
						if(res.data===true){
								window.location.href="login.html";
								alert("注册成功");
							}else{
								alert("注册失败")
							}
					});
			}
		}
		</script>
	</head>
	<body>
		<!-------------------reg-------------------------->
		<div class="reg">
			<form action="#" method="post">
				<h1 style="padding-bottom: 0px;"><img style="width: 240px;height: 79px;" src="img/temp/logo.png"></h1>
				<p>用户注册</p>
				<p><input type="text" id="utele"  value="" placeholder="请输入电话"></p>
				<p><input type="text" id="uname" value="" placeholder="请输入用户名"></p>
				<p><input type="password" id="upwd" value="" placeholder="请输入密码"></p>
				<p><input type="password" id="upass" value="" placeholder="请确认密码"></p>
				<p style="display: none"><input type="text" id="umoney" value="" placeholder="请确认密码"></p>
				<p><input type="button" style="width:280px;background: #C10000;font-size: 20px;border:none;color:#fff;" class="btn btn" name="" value="注册" onclick="reg()"></p>
				<p class="txtL txt">完成此注册，即表明您同意了我们的<a href="#"><使用条款和隐私策略></a></p>
				<p class="txt"><a href="login.html"><span></span>已有账号登录</a></p>
				<!--<a href="#" class="off"><img src="img/temp/off.png"></a>-->
			</form>
		</div>
	</body>
</html>
